package com.hns.tool.pub;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
/**
 * 获取request和respone工具
 * @author:Fisher
 * @email:zhuangcaijin@126.com
 * @version Revision 2.0.0
 */
public class ContextHolderUtils {
	/**
	 * SpringMvc下获取request
	 * @return HttpServletRequest对象
	 * @author:Fisher
	 * @email:zhuangcaijin@126.com
	 */
	public static HttpServletRequest getRequest() {
		HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
		return request;
	}
	/**
	 * SpringMvc下获取session
	 * @return HttpSession对象
	 * @author:Fisher
	 * @email:zhuangcaijin@126.com
	 */
	public static HttpSession getSession() {
		HttpSession session = getRequest().getSession();
		return session;

	}

}
